home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Wipes ƒ / Mr. Do.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.9 KB  |  158 lines  |  [TEXT/MMCC]

  1. #include "timing.h"
  2.  
  3. #define        BoxSize    4
  4. #define CorrectTime 1
  5. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  6. #define theWindowWidth (boundsRect.right-boundsRect.left)
  7.  
  8. pascal short MrDo(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  9.  
  10. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern
  11.    and alternatively scroll it up or down. */
  12.    
  13. pascal short MrDo(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  14. {
  15.     short            x, y;
  16.     short            vgap,hgap;
  17.     Rect        theRect, dest;
  18.     Rect        bounds[25];
  19.     Boolean        everyOther=FALSE;
  20.     
  21.     vgap=theWindowHeight/5;
  22.     hgap=theWindowWidth/5;
  23.     
  24.     for (x=0; x<25; x++)
  25.     {
  26.         switch (x)
  27.         {
  28.             case 0:
  29.             case 1:
  30.             case 2:
  31.             case 3:
  32.             case 4:
  33.                 bounds[x].top=0;
  34.                 break;
  35.             case 15:
  36.             case 16:
  37.             case 17:
  38.             case 18:
  39.             case 5:
  40.                 bounds[x].top=vgap;
  41.                 break;
  42.             case 14:
  43.             case 23:
  44.             case 24:
  45.             case 19:
  46.             case 6:
  47.                 bounds[x].top=vgap*2;
  48.                 break;
  49.             case 13:
  50.             case 22:
  51.             case 21:
  52.             case 20:
  53.             case 7:
  54.                 bounds[x].top=vgap*3;
  55.                 break;
  56.             case 12:
  57.             case 11:
  58.             case 10:
  59.             case 9:
  60.             case 8:
  61.                 bounds[x].top=vgap*4;
  62.                 break;
  63.         }
  64.         switch (x)
  65.         {
  66.             case 0:
  67.             case 15:
  68.             case 14:
  69.             case 13:
  70.             case 12:
  71.                 bounds[x].left=0;
  72.                 break;
  73.             case 1:
  74.             case 16:
  75.             case 23:
  76.             case 22:
  77.             case 11:
  78.                 bounds[x].left=hgap;
  79.                 break;
  80.             case 2:
  81.             case 17:
  82.             case 24:
  83.             case 21:
  84.             case 10:
  85.                 bounds[x].left=hgap*2;
  86.                 break;
  87.             case 3:
  88.             case 18:
  89.             case 19:
  90.             case 20:
  91.             case 9:
  92.                 bounds[x].left=hgap*3;
  93.                 break;
  94.             case 4:
  95.             case 5:
  96.             case 6:
  97.             case 7:
  98.             case 8:
  99.                 bounds[x].left=hgap*4;
  100.                 break;
  101.         }
  102.         bounds[x].bottom=bounds[x].top+vgap;
  103.         bounds[x].right=bounds[x].left+hgap;
  104.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  105.     }
  106.     
  107.     for (y=0; y<25; y++)
  108.     {        
  109.         if (y%2)   /* these scroll up */
  110.         {
  111.             dest=bounds[y];
  112.             dest.top=dest.bottom-BoxSize;
  113.             
  114.             theRect=bounds[y];
  115.             theRect.bottom=theRect.top+BoxSize;
  116.             
  117.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  118.             {
  119.                 StartTiming();
  120.                 ScrollTheRect(&bounds[y], 0, -BoxSize, 0L);
  121.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  122.                         &theRect, &dest, 0, 0L);
  123.                 theRect.bottom+=BoxSize;
  124.                 theRect.top+=BoxSize;
  125.                 if (everyOther)
  126.                     TimeCorrection(CorrectTime);
  127.                 everyOther=!everyOther;
  128.             }
  129.         }
  130.         else    /* these scroll down */
  131.         {
  132.             dest=bounds[y];
  133.             dest.bottom=dest.top+BoxSize;
  134.             
  135.             theRect=bounds[y];
  136.             theRect.top=theRect.bottom-BoxSize;
  137.             
  138.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  139.             {
  140.                 StartTiming();
  141.                 ScrollTheRect(&bounds[y], 0, BoxSize, 0L);
  142.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  143.                         &theRect, &dest, 0, 0L);
  144.                 theRect.bottom-=BoxSize;
  145.                 theRect.top-=BoxSize;
  146.                 if (everyOther)
  147.                     TimeCorrection(CorrectTime);
  148.                 everyOther=!everyOther;
  149.             }
  150.         }
  151.         
  152.         CopyBits(&(sourceGrafPtr->portBits),&(destGrafPtr->portBits),
  153.                     &bounds[y],&bounds[y],0,0L);
  154.     }
  155.     
  156.     return 0;
  157. }
  158.